/**
 * 项目通用饼图
 * X轴为category，Y轴value
 */
function pie(dataJson) {
    var seriesType = []
       //第一行legend标签数据
       seriesType.push({
           type: 'pie',
           // 设置item显示数值
            label: {
                show: false,
                color: '#fff',
                textStyle: {
                               color: '#fff',
                               fontSize: 8,
                           }
            },
       })
       option = {
           legend: {
              show:true,
//                orient: 'vertical',
                 left: 'left',
                 itemWidth: 6,
                 itemHeight: 6,
                 textStyle: {
                                 color: '#fff',
                                 fontSize: 8,
                             }
              },
           dataset: {
               source: dataJson
           },
           // Declare several bar series, each will be mapped
           // to a column of dataset.source by default.
           series: seriesType
       };

       console.log("pie opytions: " + JSON.stringify(option))

       return option
   }



/**
 * 项目通用3个拼图
 */
function threePie(dataJson) {
    var seriesType = []
       //第一行legend标签数据
       seriesType.push(
          {
               type: 'pie',
               radius: 50,
               center: ['25%', '50%'],
               datasetIndex: 1
             },
             {
               type: 'pie',
               radius: 50,
               center: ['50%', '50%'],
               datasetIndex: 2
             },
             {
               type: 'pie',
               radius: 50,
               center: ['75%', '50%'],
               datasetIndex: 3
             }
       )
       option = {
           legend: {
              show:true,
//                orient: 'vertical',
                 left: 'left',
                 itemWidth: 6,
                 itemHeight: 6,
                 textStyle: {
                                 color: '#fff',
                                 fontSize: 8,
                             }
              },
           dataset: {
               source: dataJson
           },
           // Declare several bar series, each will be mapped
           // to a column of dataset.source by default.
           series: seriesType
       };

       console.log("pie opytions: " + JSON.stringify(option))

       return option
   }


/**
 * 项目通用显示Label饼图
 * X轴为category，Y轴value
 */
function labelPie(dataJson,textColor) {
    var seriesType = []
       //第一行legend标签数据
       seriesType.push({
           type: 'pie',

       itemStyle: {
                 normal: {
                 label:{
                           show: true,
                           color: textColor,
                           fontSize: 10,
                           formatter: function(a){
                               return a.value[0] + '\n' + a.value[1];
                           }
                 },
                   color: function (colors) {
                      var colorList = [
                        '#5771e9',
                        '#e5b777',
                        '#999b9e',
                        '#dc6b6d',
                        '#40bdf1',
                        '#c940f1',
                        '#e90164',
                        '#009d4a',
                        '#ff4800',
                        '#4223ff',
                        '#8cd5c2',
                        '#FFD700',
                        '#C71585',
                        '#6A5ACD',
                        '#00FA9A',
                        '#CD5C5C',
                        '#CD5C5C',
                        '#D3D3D3',
                        '#7FFF00',
                        '#FFFF00',
                        '#808000',
                        '#1E90FF',
                        '#9370DB',
                        '#3CB371',
                        '#DB7093',
                        '#00008B',
                        '#3CB371',
                        '#FFFACD',
                        '#B22222',
                        '#696969',
                        '#FF00FF',
                        '#191970',
                        '#90EE90',
                        '#FFEFD5',
                        '#FF7F50',
                        '#800000',
                        '#DB7093',
                        '#BA55D3',
                        '#000080',
                        '#D4F2E7',
                        '#F0FFF0',
                        '#FAFAD2',
                        '#FFA07A',
                        '#8B0000',
                        '#9932CC',
                        '#6495ED',
                        '#008B8B',
                        '#228B22',
                        '#FFE4B5',
                        '#FF4500',
                        '#A9A9A9',
                        '#A52A2A',
                      ];
                      return colorList[colors.dataIndex];
                    }
                  },
                }
            })

       option = {
           legend: {
              show:false,
//                orient: 'vertical',
                 left: 'left',
                 itemWidth: 6,
                 itemHeight: 6,
                 textStyle: {
                           color: textColor,
                           fontSize: 8,
                  }
              },
           dataset: {
               source: dataJson
           },
           // Declare several bar series, each will be mapped
           // to a column of dataset.source by default.
           series: seriesType
       };

       console.log("pie opytions: " + JSON.stringify(option))

       return option
   }

